package com.jxm.annotation;

import com.jxm.validation.CheckValueValidator;
import jakarta.validation.Constraint;
import jakarta.validation.Payload;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 枚举校验注解
 */
@Target({FIELD})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {CheckValueValidator.class})
public @interface CheckValue {

    // 默认错误消息
    String message() default "必须为指定值";

    //校验值
    String[] strValues() default {};

    VerifyEnum enumValue() default @VerifyEnum(key = "校验不生效", enumValue = Enum.class);

    // 分组
    Class<?>[] groups() default {};

    // 负载
    Class<? extends Payload>[] payload() default {};
}